//! @Author: DengLibin 榆霖
//! @Date:  2022-07-06 09:16:07
//! @Description: 

use snowflake::SnowflakeIdGenerator;

pub struct IdGenerator {
    generator: SnowflakeIdGenerator,
}

impl IdGenerator {
    pub fn new(machine_id: i32, node_id: i32) -> Self {
        IdGenerator {generator: SnowflakeIdGenerator::new(machine_id, node_id)}
    }

    pub fn next_id(&mut self) -> i64 {
        self.generator.real_time_generate() - 6950255325782085633_i64
    }
}